#include "MLTools_TxtFileSaver.h"
_MYLABLIB_BEGIN
CMLTools_TxtFileSaver::CMLTools_TxtFileSaver(void)
{
}

CMLTools_TxtFileSaver::~CMLTools_TxtFileSaver(void)
{
}

int CMLTools_TxtFileSaver::Initialize(const std::wstring& wstrFileName, int bAppend /* = false*/)
{
	if (bAppend)
	{
		m_FileStream.open(wstrFileName.c_str(), std::ios::out | std::ios::app);
	}
	else
	{
		m_FileStream.open(wstrFileName.c_str());
	}

	if (m_FileStream.fail())
		return -1;
	else
		return 0;
}

int CMLTools_TxtFileSaver::Save(const CMLDataSet& dataSet)
{
	int i;
	for (i=0; i<dataSet.Count(); i++)
	{
		m_FileStream << dataSet.Get(i).ToWString() << L'\n';
	}
	return 0;
}

void CMLTools_TxtFileSaver::Close()
{
	m_FileStream.close();
}


_MYLABLIB_END
